import json

from channels.generic.websocket import WebsocketConsumer
from channels.exceptions import StopConsumer
import time
import random

class ChatConsumer(WebsocketConsumer):
    def websocket_connect(self, message):
        print("websocket连接已建立")
        self.accept()
        self.send("欢迎来到我的站点！！！")

    def websocket_receive(self, message):
        print(message)

    def websocket_disconnect(self, message):
        raise StopConsumer()
